home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snpd9611.zip / MAXLINE.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  931b  |  48 lines

  1. /* +++Date last modified: 17-Nov-1996 */
  2.  
  3. /*
  4. ** maxline.c - returns the length of the longest line in text file
  5. **
  6. ** Released to Public Domain by Phi Nguyen
  7. **
  8. ** 03.22.96 - First release
  9. ** 03.26.96 - Chad Wallace, for use with FILECAT.C
  10. **              Uses an array of pointers to strings (ala argv)
  11. **              instead of a file.
  12. */
  13.  
  14. #include <stdio.h>
  15.  
  16. unsigned int max_line(char ** str_array)
  17. {
  18.       unsigned cur_len, max = 0;
  19.  
  20.       while (*str_array != NULL)
  21.       {
  22.             cur_len = strlen(*str_array);
  23.             if (cur_len > max)
  24.                   max = cur_len;
  25.  
  26.             str_array++;
  27.       }
  28.  
  29.       return max;
  30. }
  31.  
  32. #ifdef TEST
  33.  
  34. /*
  35. ** Will return the length of the largest parameter given on the
  36. ** command line, including argv[0], the program's .EXE file.
  37. */
  38.  
  39. main(int argc, char **argv)
  40. {
  41.       printf("%i\n", max_line(argv));
  42.  
  43.       return 0;
  44. }
  45.  
  46. #endif
  47.  
  48.